import React, {Component} from 'react';
import Markdown from 'react-markdown';
import {Anchor, Row, Col} from 'antd';

const {Link} = Anchor;

class JsPage extends Component {
    constructor(props) {
        super(props);
    }


    render() {

        return (
            <div style={{background:"#c0d2bc"}}>
                <Row>
                    <Col span={19}>
                        <h3 id="foreach_map"> map的遍历 </h3>
                        <Markdown source={"方式一、最常见的并且在大多数情况下也是最可取的遍历方式。在键值都需要时使用。\n" +
                        "\n" +
                        "    Map<Integer, Integer> map = new HashMap<Integer, Integer>(); \n" +
                        "    for (Map.Entry<Integer, Integer> entry : map.entrySet()) { \n" +
                        "        System.out.println(\"Key = \" + entry.getKey() + \", Value = \" + entry.getValue()); \n" +
                        "    }\n" +
                        "方法二、在for-each循环中遍历keys或values。\n" +
                        "\n" +
                        "    Map<Integer, Integer> map = new HashMap<Integer, Integer>(); \n" +
                        "    //遍历map中的键 \n" +
                        "    for (Integer key : map.keySet()) { \n" +
                        "      System.out.println(\"Key = \" + key); \n" +
                        "    } \n" +
                        "    //遍历map中的值 \n" +
                        "    for (Integer value : map.values()) { \n" +
                        "      System.out.println(\"Value = \" + value); \n" +
                        "    }\n" +
                        "\n" +
                        "方法三、使用Iterator遍历\n" +
                        "\n" +
                        "    Map<Integer, Integer> map = new HashMap<Integer, Integer>(); \n" +
                        "    Iterator<Map.Entry<Integer, Integer>> entries = map.entrySet().iterator(); \n" +
                        "    while (entries.hasNext()) { \n" +
                        "      Map.Entry<Integer, Integer> entry = entries.next(); \n" +
                        "      System.out.println(\"Key = \" + entry.getKey() + \", Value = \" + entry.getValue()); \n" +
                        "    }\n" +
                        "\n" +
                        "方法四、通过键找值遍历（效率低）\n" +
                        "    \n" +
                        "    Map<Integer, Integer> map = new HashMap<Integer, Integer>(); \n" +
                        "    for (Integer key : map.keySet()) { \n" +
                        "      Integer value = map.get(key); \n" +
                        "      System.out.println(\"Key = \" + key + \", Value = \" + value);\n" +
                        "\n" +
                        "建议使用方法三;"}/>

                    </Col>

                </Row>
            </div>

        );
    }
}

export default JsPage;